package com.gen;

import java.util.ArrayList;
import java.util.List;

import com.framework.tools.DBColumn;

@SuppressWarnings({ "rawtypes", "unchecked" })
public class ColumnSource
{
private List<DBColumn> updateColumns = new ArrayList();

  private List<DBColumn> pkColumns = new ArrayList();

  private List<DBColumn> updateBeforePk = new ArrayList();

  protected List<DBColumn> columns = null;

  public ColumnSource(List<DBColumn> columns) {
    this.columns = columns;
    splitColumn();
    reset();
  }

  private void splitColumn() {
    for (int i = 0; i < this.columns.size(); ++i) {
      DBColumn c = (DBColumn)this.columns.get(i);
      if (c.isPrimaryKey())
        this.pkColumns.add(c);
      else
        this.updateColumns.add(c);
    }
  }

  private void reset()
  {
    this.updateBeforePk.addAll(this.updateColumns);
    this.updateBeforePk.addAll(this.pkColumns);
  }

  public List<DBColumn> getUpdateColumns() {
    return this.updateColumns;
  }

  public void setUpdateColumns(List<DBColumn> updateColumns) {
    this.updateColumns = updateColumns;
  }

  public List<DBColumn> getPkColumns() {
    return this.pkColumns;
  }

  public void setPkColumns(List<DBColumn> pkColumns) {
    this.pkColumns = pkColumns;
  }

  public List<DBColumn> getUpdateBeforePk() {
    return this.updateBeforePk;
  }

  public void setUpdateBeforePk(List<DBColumn> updateBeforePk) {
    this.updateBeforePk = updateBeforePk;
  }

  public List<DBColumn> getColumns() {
    return this.columns;
  }

  public void setColumns(List<DBColumn> columns) {
    this.columns = columns;
  }
}